#pragma once

#include <memory>
#include "Containers/Vector.h"
#include "Containers/String.h"
#include "Containers/Optional.h"

class CScriptFileContext;
class CScriptToken;

class CTokenGenerator
{
public:    
    CTokenGenerator(std::shared_ptr<CScriptFileContext> InContext);


    void GenerateTokens();

protected:
    //std::shared_ptr<CScriptToken> CreateToken(std::shared_ptr<CScriptFileContext> InContext,const CString& InWord);

    //return true is no error
    bool TryCreateToken();

    //return true if successfullly create a token
    bool TryCreateKeywordToken(CString InWord);

    std::shared_ptr<CScriptFileContext> Context;


    uint64_t CharIndex=0;
    uint64_t LineIndex=0;  //start from 0
    uint64_t ColumnIndex=0; //start from 0

    char32_t GetCurrentChar() const;
    char32_t GetNextChar() const;   

    void GotoNextChar();

    TOptional<char32_t> ReadEscapeChar();
};